package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.WeiChatDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/*
  http://localhost:8080/v1/users/login
 */
@Controller
public class UserController {

    @RequestMapping(value = "/v1/users/login")
    @ResponseBody
    public String login() {
        return "恭喜你,登陆成功";
    }

    @RequestMapping(value = "/v1/users/reg")
    @ResponseBody
    public String reg(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        return username + "-" + password;
    }

    /*
    http://localhost:8080/v1/users/changepwd?username=&newpwd=
     */
    @RequestMapping(value = "v1/users/changepwd")
    @ResponseBody
    public String changepwd(String username, String newpwd) {
        return username + "-" + newpwd;
    }

    @RequestMapping("v1/users/weiChat")
    @ResponseBody
    public String weiChat(WeiChatDTO weiChatDTO) {
        String name = weiChatDTO.getName();
        String pwd = weiChatDTO.getPwd();
        return name + "-" + pwd;
    }
}